//
//  LLMyCourseTableViewCell.m
//  LoveLove
//
//  Created by 达迩科技 on 2019/4/10.
//  Copyright © 2019 wkf. All rights reserved.
//

#import "LLMyCourseTableViewCell.h"

@implementation LLMyCourseTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
    }
    return self;
}

- (void)initView{
    
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, LLScreenWidth-20, 188)];
    bgView.layer.masksToBounds = YES;
    bgView.layer.cornerRadius = 15;
    bgView.backgroundColor = LLWhiteColor;
    [self.contentView addSubview:bgView];
    
    self.bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(16, 15, 93, 93)];
    self.bgImage.image = [UIImage imageNamed:@"课程图片"];
    self.bgImage.layer.masksToBounds = YES;
    self.bgImage.layer.cornerRadius = 5;
    self.bgImage.contentMode = UIViewContentModeScaleAspectFill;
    [bgView addSubview:self.bgImage];
    
    self.titleLabel = [LLInitBaseViewTool labelWithText:@"满200-100元优惠券满200-100元优惠券优惠券满200-100元优惠券券元.." textColor:LLColorRGB(0) font:13 textAlignment:NSTextAlignmentLeft];
    self.titleLabel.numberOfLines = 2;
    self.titleLabel.frame = CGRectMake(122, 15, bgView.width-122-15, 35);
    [bgView addSubview:self.titleLabel];
    
    self.priceLabel = [LLInitBaseViewTool labelWithText:@"￥1  付款200人" textColor:LLColorRGB(116) font:10 textAlignment:NSTextAlignmentLeft];
    self.priceLabel.frame = CGRectMake(122, 67, LLScreenWidth-122-15, 13);
    [bgView addSubview:self.priceLabel];
    NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:self.priceLabel.text];
    NSRange range1 = [self.priceLabel.text rangeOfString:@"1"];
    [AttributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:13] range:range1];
    NSRange range11 = [self.priceLabel.text rangeOfString:@"1"];
    [AttributedStr addAttribute:NSForegroundColorAttributeName value:LLColor(231, 11, 11) range:range11];
    NSRange range2 = [self.priceLabel.text rangeOfString:@"￥"];
    [AttributedStr addAttribute:NSForegroundColorAttributeName value:LLColor(231, 11, 11) range:range2];
    self.priceLabel.attributedText = AttributedStr;
    
    self.subtitleLabel = [LLInitBaseViewTool labelWithText:@"浏览200   留言20   点赞50   分享10" textColor:LLColorRGB(116) font:10 textAlignment:NSTextAlignmentLeft];
    self.subtitleLabel.frame = CGRectMake(122, 98, LLScreenWidth-122-15, 10);
    [bgView addSubview:self.subtitleLabel];
    
    UIView *lineview = [[UIView alloc] initWithFrame:CGRectMake(0, 124, bgView.width, 0.5)];
    lineview.backgroundColor = LLColorRGBAlpha(67, 67, 67, 0.5);
    [bgView addSubview:lineview];
    
    NSArray *titleArray = @[@"编 辑",@"更 多"];
    for (int i=0; i<titleArray.count; i++) {
        LLButton *button = [LLInitBaseViewTool buttonWithTitle:titleArray[i] image:nil titleColor:LLColorRGB(95) font:15];
        button.layer.masksToBounds = YES;
        button.layer.cornerRadius= 13.5;
        button.tag = i;
        button.layer.borderColor = LLColorRGB(128).CGColor;
        button.layer.borderWidth = 1;
        if (i==0) {
            button.frame = CGRectMake(bgView.width-15-76*2-17, 146, 76, 27);
        } else {
            button.frame = CGRectMake(bgView.width-15-76, 146, 76, 27);
        }
        [button addTarget:self action:@selector(didSelectType:) forControlEvents:UIControlEventTouchUpInside];
        [bgView addSubview:button];
    }
}

- (void)didSelectType:(LLButton *)button{
    if (self.delegate && [self.delegate respondsToSelector:@selector(didSelectButton:didClickItem:)]) {
        [self.delegate didSelectButton:self didClickItem:button.tag];
    }
}
-(void)configLLMyCourseTableViewCell:(LLMyPublishModel *)model{
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
